/**
 *
 */
package com.iis.hrms.service.impl;

import com.iis.hrms.dao.GenericDAO;
import com.iis.hrms.persistence.User;
import com.iis.hrms.service.LoginService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author firdaus
 */
@Service
public class LoginServiceImpl implements LoginService {

    private Logger log = Logger.getLogger(LoginServiceImpl.class);

    @Autowired
    private GenericDAO genericDAO;
    /* (non-Javadoc)
      * @see com.iis.hrms.service.LoginService#validation(java.lang.String, java.lang.String)
      */

    @Override
    public boolean validation(String username, String password) {
        boolean result = false;
        User user;
        user = (User) genericDAO.selectObject("User.findByUsername", username, "username");
        if (user != null) {
            log.info("User " + username + " Exists");
            if (password.equals(user.getPassword()))
                result = true;
        }
        return result;
    }

}
